package com.sky.security;

import java.lang.reflect.Method;

/**
 * @author : wushikai
 * <p>
 * date : 2022-05-07
 */
public class SecurityDemo {

    public static void main(String[] args) {
        System.setSecurityManager(new SecurityManager()); // 设置了 SecurityManager   禁用反射
        Class securityClass = Security.class;
        try {
            Security security = (Security) securityClass.newInstance();
            Method method = securityClass.getDeclaredMethod("changeSecurity");
            method.setAccessible(true);
            System.out.println("Security level: " + security.getSecurity());
            method.invoke(security);
            System.out.println("Security level: " + security.getSecurity());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}




